<?php
namespace App\Services;

use Framework\BaseService;
use Qiniu\Auth;
use Qiniu\Http\Client;
use Qiniu\Rtc\AppClient;

class QiNiuService extends BaseService
{


    private $auth;
    private $bucket;
    private $rtc;
    public function __construct()
    {

        $access_key =  config('filesystems.disks.qiniu.access_key');
        $secret_key = config('filesystems.disks.qiniu.secret_key');
        $this->bucket = config('filesystems.disks.qiniu.bucket');
        $this->auth  = new Auth($access_key,$secret_key);

        $this->rtc = new AppClient($this->auth);
    }


    /**
     * 获取七牛token
     * @return array
     */
    public function getQiNiuToken()
    {
        $policy = null;
        $expires = 86400;
        $url = config('filesystems.disks.qiniu.domains.default');
        $bucket =$this->bucket;
        $token =  $this->auth->uploadToken($bucket,null, $expires, $policy, true);
        return compact('token','url','bucket');
    }






}
